<?php
$xmlDoc = new DOMDocument();
$xmlDoc->load("questions.xml");

$english = $xmlDoc->getElementsByTagName("english");
srand(time());
$i = 0;
while ( $i < 8 ) {
	$random = (rand()%$english->length);
	$eval = $english->item($random)->nodeValue;
	$kval = $english->item($random)->parentNode->getElementsByTagName("korean")->item(0)->nodeValue;
	$found = 0;
	for ( $j = 0; $j < sizeof($evalues); $j++ ) {
			if ( $evalues[$j] == $eval ) {
				$found = 1;
				break;
			}
	}
	if ( $found != 1 ) {
		$evalues[$i] = $eval;
		$kvalues[$i++] = $kval;
	}
}
$msg = "";
for ( $j = 0; $j < 8; $j++ ) {
	$msg .= $evalues[$j] . ",";
	$msg .= $kvalues[$j];
	if ( $j < 7 ) {
		$msg .= ";";
	}
}
echo $msg;
?>
